﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>手动子流程</title>
    <link href="../../../Comm/Style/CommStyle.css" rel="stylesheet" type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" />
    <script src="../../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../../Comm/Gener.js"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <!-- 自己的系统风格统一. -->
    <link href="../../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../../Style/skin/css/Default.css" rel="stylesheet" />
    <link href="../../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

    <base target="_self" />
    <script src="../../Admin.js"></script>
    <script type="text/javascript">
        //打开窗体.
        function OpenEasyUiDialogExt(url, title, w, h, isReload) {

            OpenEasyUiDialog(url, "eudlgframe", title, w, h, "icon-property", true, null, null, null, function () {
                if (isReload == true) {
                    Reload();
                }
            });
        }

        //页面启动函数.
        $(function () {

            $("#Msg").html("<img src=../../../Img/loading.gif />&nbsp;正在加载,请稍后......");

            //求出来已经设置的延续子流程.
            var nodeID = GetQueryString("FK_Node");
            var ens = new Entities("BP.WF.Template.SFlow.SubFlowHands");
            ens.Retrieve("FK_Node", nodeID, "SubFlowType", 0, "Idx");

            var node = new Entity("BP.WF.Node", nodeID);
            node.SetPara("SubFlowHandNum", ens.length);
            node.Update();

            $("#Btn_AddGroup").hide();
            var webUser = new WebUser();
            if (webUser.CCBPMRunModel == 1) {
                $("#Btn_AddGroup").show();
            }


            //console.log(ens);

            var html = "";
            for (var i = 0; i < ens.length; i++) {
                var en = ens[i];
                html += "<tr>";
                html += "<td class=Idx>" + (i + 1) + "</td>";
                html += "<td>" + en.SubFlowNo + "</td>";

                var enSub = new Entity("BP.WF.Flow", en.SubFlowNo);

                //  html += "<td>" + en.SubFlowName + "</td>";
                html += "<td>" + enSub.Name + "</td>";

                html += "<td>" + en.SubFlowModelText + "</td>";

                html += "<td>" + en.SubFlowStaText + "</td>";


                html += "<td><a href=\"javascript:Edit('" + en.MyPK + "');\" >编辑</a></td>";
                html += "<td><a href=\"javascript:Delete('" + en.MyPK + "');\" >删除</a></td>";
                html += "<td>";
                html += "<a href=\"javascript:DoUp('" + en.MyPK + "')\">上移</a> - <a href=\"javascript:DoDown('" + en.MyPK + "')\">下移</a>";
                html += "</td>";
                html += "</tr>";
            }

            $("#Table1 tr:last").after(html);

            $("#Msg").html("");

        });

        function DoUp(mypk) {
            var en = new Entity("BP.WF.Template.SFlow.SubFlowHand", mypk);
            en.DoMethodReturnString("DoUp");
            Reload();
        }
        function DoDown(mypk) {
            var en = new Entity("BP.WF.Template.SFlow.SubFlowHand", mypk);
            en.DoMethodReturnString("DoDown");
            Reload();
        }

        //查询集团的流程.
        function AddGroup() {
            var webUser = new WebUser();

            var url = "SubFlowHandDtl.htm?FK_Node=" + GetQueryString("FK_Node") + "&OrgNo=" + webUser.GroupNo;
            OpenEasyUiDialogExt(url, "选择子流程", 700, 600, true);
        }
        //查询集团的流程.
        function AddOrg() {
            var webUser = new WebUser();
            var url = "SubFlowHandDtl.htm?FK_Node=" + GetQueryString("FK_Node") + "&OrgNo=" + webUser.FK_Dept;
            OpenEasyUiDialogExt(url, "选择子流程", 700, 600, true);
        }

        //删除成功.
        function Delete(pk) {

            if (confirm('您确定要删除吗？') == false)
                return;

            var en = new Entity("BP.WF.Template.SFlow.SubFlowHand", pk);
            en.Delete();
            Reload();
        }

        //编辑.
        function Edit(pk) {

            // var url = "../../../Comm/RefFunc/EnOnly.htm?EnName=BP.WF.Template.SFlow.SubFlowHand&PKVal=" + pk;
            var url = "../../../Comm/RefFunc/En.htm?EnName=BP.WF.Template.SFlow.SubFlowHand&PKVal=" + pk;

            OpenEasyUiDialogExt(url, '编辑', 900, 800, true);
            //window.location.href = url;

        }
        function Help() {
            var url = "https://gitee.com/opencc/JFlow/wikis/pages/preview?sort_id=3982373&doc_id=31094";
            window.open(url);
        }
    </script>
</head>
<body>
    <div class="container-full">
        <div class="attrnode-bar-header">

            <span class="pull-right">
                <button id="Btn_AddGroup" name="Btn_AddGroup" onclick="AddGroup();">增加集团子流程</button>
                <button id="Btn_AddMyOrg" class="cc-btn-tab btn-batch" name="Btn_AddMyOrg" onclick="AddOrg();">增加本组织子流程</button>
                <button id="Btn_Help" name="Btn_Help" onclick="Help();">帮助</button>
            </span>

            <!--<span class="pull-right">
                <button id="Btn_New" name="Btn_New" onclick="AddGroup();">增加子流程</button>
                <button id="Btn_Help" name="Btn_Help" onclick="Help();">帮助</button>
            </span>-->
            <!--<strong>
                手动子流程- <a href="javascript:ShowHidden('img')">运行效果</a>
            </strong>-->
        </div>

        <table id="Table1" style="width: 95%" class="table">

            <tr>
                <th>
                    序
                </th>
                <th>
                    编号
                </th>
                <th>
                    流程名称
                </th>
                <th>
                    模式
                </th>
                <th>
                    状态
                </th>
                <th>
                    编辑
                </th>

                <th>
                    删除
                </th>
                <th>
                    顺序
                </th>
            </tr>
        </table>
        <br />
        <!--<input type="button" value="增加集团子流程" onclick="AddGroup()" />
        <input type="button" value="增加本组织子流程" onclick="AddOrg()" />-->

        <div style="position:relative;" id="Msg">
        </div>

        <fieldset id="img">
            <legend>帮助</legend>
            <ul>
                <li> 手工启动的子流程，依附于子流程组件。</li>
                <li> 使用子流程组件，可以启用一个或者多个子流程。</li>
            </ul>
            <img src="SubFlowHand-1.png" class="HelpImg" style="width:50%;" />

        </fieldset>
</body>
</html>
